#include <memory>
#include "Reactor.hpp"
#include "Connection.hpp"
#include "ListenService.hpp"
#include "Common.hpp"

using namespace wxd;
int main(int argc,char* argv[])
{
    if(argc != 2)
    {
        std::cerr<<"Usage: "<<argv[0]<<" port"<<std::endl;
        exit(USAGE_ERR);
    }

    u_int16_t port = std::stoi(argv[1]);
    // std::cout<<port<<std::endl;
    //创建Reatcor
    std::unique_ptr<Reactor> reactor_ptr = std::make_unique<Reactor>();
    //创建ListenService插入Reactor
    std::shared_ptr<Connection> con_listen_ptr = std::make_shared<Listen>(port);
    reactor_ptr->InsertConnection(con_listen_ptr);
    //启动Reactor（循环等待-派发事件）
    reactor_ptr->Start();
}